/**
 * 判断token的有效性
 */
const auth = ()=>{
    return new Promise(function(resolve,reject){
        var token = wx.getStorageSync('vl_token');
        if(token == ''){
            resolve(false);
            return;
        }
        //请求后台判断token
        wx.Khttp.get('/validateToken')
        .then(res => {
            if(res.data.code == 400){
                resolve(false);
                return;
            }
            resolve(true);
        })
        .catch(err=>{
            reject(err);
        })
    })
}

module.exports = {
    auth
  }